package org.cx.oa.web.struts.actions;

import java.util.ArrayList;
import java.util.List;

import org.cx.oa.entity.Employee;
import org.cx.oa.entity.UserBasicInfomation;
import org.cx.oa.entity.WorkTime;
import org.cx.oa.service.WorkTimeService;
import org.cx.oa.util.BeanFactory;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class WorkTimeAction  extends ActionSupport{
	
	private WorkTime workTime=new WorkTime();
	private int id;
	
	private List<WorkTime> list=new ArrayList<WorkTime>();
	private WorkTimeService workTimeService=BeanFactory.getImpl(WorkTimeService.class);
	
	
	public String execute(){
		list=workTimeService.FindAll();
		return SUCCESS;
	}
	
	public String selectId(){
		workTime=workTimeService.ById(id);
		return "update";
	}
	
	public String update(){
		workTime.setId(id);
		
		ActionContext context=ActionContext.getContext();
		
		Employee user=(Employee) context.getSession().get("user");
		
		Employee employee=new Employee();
		employee.setUserId(user.getUserId());
		
		workTime.setEmployee(employee);
		workTimeService.Update(workTime);

		list=workTimeService.FindAll();
		
		return SUCCESS;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public WorkTime getWorkTime() {
		return workTime;
	}

	public void setWorkTime(WorkTime workTime) {
		this.workTime = workTime;
	}


	public List<WorkTime> getList() {
		return list;
	}


	public void setList(List<WorkTime> list) {
		this.list = list;
	}
	
	
}